a = input().split() 
n = ''

for k in a:
    if k == 'zero':
        n += '0'
    if k == 'one':
        n += '1'
    if k == 'two':
        n += '2'
    if k == 'three':
        n += '3'
    if k == 'four':
        n += '4'
    if k == 'five':
        n += '5'
    if k == 'six':
        n += '6'
    if k == 'seven':
        n += '7'
    if k == 'eight':
        n += '8'
    if k == 'nine':
        n += '9'


def prostoe(x): 
    if not x % 2:
        return x == 2
    p = 3
    while p * p <= x and x % p:
        p+= 2
    return p * p > x 


n1 = int(n)

if 99 < n1 < 1000:
    f= abs(n1 - 2)
    r = 2
    l = 3
    while True:
        if prostoe(l):
            t = abs(n1 - l)
            if t < f:
                f = t
                r = l
            else:
                print(r)
                break 
        l += 2
else:
    print('Wrong input')